package atom.core3.spring.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.log4j.Logger;

import atom.core0.util.StringUtil;
import atom.core3.spring.dubbo.DubboContext;

public class DubboInitServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static Logger log = Logger.getLogger(DubboInitServlet.class);
	public void init() throws ServletException {
		super.init();
		
		try
		{
			String dubbo_server = getInitParameter("dubbo_server");	
			if(StringUtil.isEmpty(dubbo_server))
				log.info("dubbo_server是空,DubboInitServlet没有动态加载dubbo服务端");
			else
				DubboContext.initServer(new String[] {dubbo_server});
		}
		catch(Throwable e)
		{
			log.error("加载dubbo服务端错误",e);
		}

		try
		{
			String dubbo_client = getInitParameter("dubbo_client");	
		
			if(StringUtil.isEmpty(dubbo_client))
				log.info("dubbo_client是空,DubboInitServlet没有动态加载dubbo客户端");
			else
				DubboContext.initClient(new String[] { dubbo_client});
		}
		catch(Throwable e)
		{
			log.error("加载dubbo客户端错误",e);
		}
	}

	
}

